package com.sunyur.tailor.channel.config.middle;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 *
 * @Author 99288
 * @Description MybatisPlus配置类
 * @Date 15:13 2020/9/29
 * @Param
 * @return
**/
@EnableTransactionManagement
@Configuration
@MapperScan("com.sunyur.tailor.channel.dal.*.mapper*")
@ConditionalOnProperty(name = "mybatis-plus.switch", havingValue = "open")
public class MybatisPlusConfig {
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(Boolean.TRUE));
        return paginationInterceptor;
    }


}
